package com.cloud.flowbusdemo.fragment

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.cloud.flowbusdemo.constants.Constants
import com.cloud.flowbusdemo.databinding.FragmentMineBinding
import com.cloud.flowbusdemo.databinding.FragmentSecondBinding
import com.cloud.flowbusdemo.flow.FlowBus
import com.cloud.flowbusdemo.model.MessageEvent
import kotlinx.coroutines.launch

/**
 * @auth: njb
 * @date: 2024/9/17 18:48
 * @desc: 描述
 */
class SecondFragment : Fragment(){
    private val TAG = "SecondFragment"
    private var name: String? = null
    private var age: Int? = null
    private lateinit var binding: FragmentSecondBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentSecondBinding.inflate(layoutInflater)
        initView()
        return binding.root
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
            name = it.getString(Constants.ARG_PARAM_NAME)
            age = it.getInt(Constants.ARG_PARAM_AGE)
        }
        Log.i(TAG, "MainFragment 传递到 SecondFragment 的参数为 name = $name , age = $age")
        Log.d(TAG, "姓名:" + name + "年龄:" + age)
    }

    private fun initView() {
        binding.let {
            it.tvTitle.text = name
            it.tvAge.text  = age.toString()
        }
    }
}